<template>
  <div class="graph_container">
    <FifAdaptiveGraph v-if="isShow" :graphConfig=graphConfig></FifAdaptiveGraph>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue"
import { Getway } from "fif-utils"
// 实例化网关
const getway = new Getway({
  appCode: 'adopt',
  tokenKey: "test-token",
  baseUrl: 'https://apics.fifedu.com/',
  timeout: 5000,
  isLog: false,
  toLogin: async () => {
    // 未登录
    window.location.replace(`${'https://hecs.fifedu.com'}/iplat/fifLogin/index.html?service=${encodeURIComponent(window.location.href)}`)
  }
})

let graphConfig = ref({
  graphId: ''
})

let isShow = ref(false)

onMounted(async () => {
  // 通过网关创建Axios
  const GETWAY = await getway.createAxios()

  // 解决data返回值问题，如果项目已有，不用配置
  GETWAY.Axios.interceptors.response.use(function (response) {
    let data = response.data
    if (response.status == 200 && data.status == 1) {
      return data
    }
  }, function (error) {
    return Promise.reject(error || 'Error')
  })

  
  graphConfig.value = {
    vistsource:'1', // 访问来源 1=web授课
    classId: '', // 班级id 
    // mode: '', // dark=暗黑模式
    // knowledgeId: '', // 默认选中知识点id
    // targetId: '', //目标id，用于AI课程内嵌样式
    course:{
      courseId: '3de9a70b97544679b17adcf3f81ec7b1', // 课程id  必填
      courseInfo: {
        aimindId: '259af2465ebe4dcaaeb25b778a7f52e0', // 图谱id  必填
        aimindName: 'xg0lmgle', // 图谱名称  必填
        // personalStatus: 1, // 个性化图谱发布状态
      }
    },
    getway: GETWAY // 网关实例 如果项目已经接入网关，直接传入即可 默认测试环境
  }
  isShow.value = true
})


</script>

<style scoped>
.graph_container {
  width: 100%;
  height: 600px;
}

.graph_container>>>.container {
  height: 100%;
}
</style>
